/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ar.com.arkios.kfconsap.pruebas;

import com.sap.mw.jco.JCO;
import com.sap.mw.jco.JCO.Client;
import com.sap.mw.jco.JCO.Pool;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Ale
 */
public class TestPoolConnection {
    private static final String POOL_NAME ="ADE_ABATE";
    private Pool pool;
    private Client mConnection;
        
    //Constructor
    public TestPoolConnection(){
//        this.pool = JCO.getClientPoolManager ().getPool (POOL_NAME);
        this.startTest();
    }
    
    private void startTest() {
        if(this.pool == null){
            OrderedProperties logonProperties;
            try {
                logonProperties = OrderedProperties.load("logon.properties");
                //Params Pool Name, Max Conections, Properties File.
                JCO.addClientPool (POOL_NAME, 5, logonProperties);
                this.pool = JCO.getClientPoolManager ().getPool (POOL_NAME);
            } catch (IOException ex) {
                Logger.getLogger(TestPoolConnection.class.getName()).log(Level.SEVERE, null, ex);
                System.out.println("Error en cargar logonProperties");
            }               
        }
        try{
        mConnection = JCO.getClient(POOL_NAME);
        } catch(Exception e){
            e.printStackTrace();
        }
        System.out.println(mConnection.getAttributes());
    }

    public void closeConnection(){
        JCO.releaseClient(mConnection);
        
    }    
    
    public Client getMConnection() {
        return mConnection;
    }
    
    


    
    
    

}
